<?php
//error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
require_once('./roots.php');
require_once($root_path.'include/inc_environment_global.php');

/**
* CARE2X Integrated Hospital Information System beta 2.0.1 - 2004-07-04
* GNU General Public License
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/

define('LANG_FILE','usuarios.php');
define('NO_2LEVEL_CHK',1);
require_once($root_path.'include/inc_front_chain_lang.php');

$thisfile=basename(__FILE__);
$breakfile='usuarios.php'.URL_APPEND;
$action='usuario-save.php'.URL_APPEND.(($update)?('update=1'):(''));

require_once($root_path.'include/care_api_classes/class_core.php');
$core=new Core;

require_once($root_path.'include/care_api_classes/class_usuario.php');
include_once($root_path.'include/inc_photo_filename_resolve.php');

//$msj = '';
$usuario = new Usuario;

# Start Smarty templating here
/**
* LOAD Smarty
*/

# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
?>
                <script  language="javascript">

                function chkform(d) {
                        if (d.name.value==""){//
                                alert("Debe introducir el nombre y apellido");
                                d.name.focus();
                                return false;
                        }else if(d.login_id.value==""){//
                                alert("Debe introducir el nombre de usuario");
                                d.login_id.focus();
                                return false;
                        }
                        <?php if (!$update) { ?>
			else if(d.password.value==""){//
                                alert("Debe introducir la contraseña");
                                d.password.focus();
                                return false;
                        }
                        else if(d.password.value.toString()!=d.password2.value.toString()){//
                                alert("La contraseña no coincide con la verificación");
                                d.password.focus();
                                return false;
                        }
					      <?php } ?>
                }

                </script>
<?php

require_once($root_path.'gui/smarty_template/smarty_care.class.php');
$smarty = new smarty_care('common');

$smarty->assign('msj',$msj);

$smarty->assign('breakfile',$breakfile);
$smarty->assign('action',$action);
$smarty->assign('reg',1);
$smarty->assign('currentUser', $_SESSION['sess_login_userid']);

$smarty->assign('sToolbarTitle',$LDUsuario);


if ($update) {
  $smarty->assign('title',$LDEditarUsuario);
  $smarty->assign('LDTipPassword',$LDTipPassword);
 } else {
  $smarty->assign('title',$LDRegUsuario);
 }

$smarty->assign('LDNombre', $LDNombre);
$smarty->assign('sNombreInput', '<input name="name" type="text" size="35" value="'. $name  .'">');

$smarty->assign('LDmatricula', $LDmatricula);
$smarty->assign('sMatriculaInput', '<input name="matricula" type="text" size="35" value="'. $matricula  .'">');

$smarty->assign('LDclasificacion', $LDclasificacion);
$smarty->assign('sClasificacionInput', '<input name="clasificacion" type="text" size="35" value="'. $clasificacion  .'">');


$smarty->assign('LDLogin', $LDLogin);
$smarty->assign('sLoginInput', '<input name="login_id" type="text" size="35" value="' . $login_id . '" ' . (($update)?("readonly"):(""))  . '>');

$smarty->assign('LDPassword', $LDPassword);
$smarty->assign('sPasswordInput', '<input name="password" type="password" size="35" value="' . $password . '">');

$smarty->assign('LDPassword2', $LDPassword2);
$smarty->assign('sPassword2Input', '<input name="password2" type="password" size="35" value="' . $password . '">');

$tipoUsuario  = '<select name="permission">';
$tipoUsuario .= '<option value="_a_1_interinterconsultante" ' . (($permission == '_a_1_interinterconsultante')?('selected'):('')) . '>M&eacute;dico (Interconsultante)</option>';
$tipoUsuario .= '<option value="_a_1_interinterconsultado" ' . (($permission == '_a_1_interinterconsultado')?('selected'):('')) . '>M&eacute;dico (Interconsultado)</option>';
$tipoUsuario .= '<option value="_a_2_intertriajewrite" ' . (($permission == '_a_2_intertriajewrite')?('selected'):('')) . '>Triaje</option>';
$tipoUsuario .= '<option value="_a_3_historiaauditor" ' . (($permission == '_a_3_historiaauditor')?('selected'):('')) . '>Auditor</option>';
$tipoUsuario .= '<option value="System_Admin" ' . (($permission == 'System_Admin')?('selected'):('')) . '>Administrador del sistema</option>';
$tipoUsuario .= '</select>';
$smarty->assign('LDTipo',$LDTipo);
$smarty->assign('sTipoSelect',$tipoUsuario);

$smarty->assign('update', '<input name="update" type="hidden" value="' . $update . '">');

$smarty->assign('pbSubmit','<input type="image" '.createLDImgSrc($root_path,'savedisc.gif','0').'  alt="'.$LDSaveData.'" align="absmiddle">');
$smarty->assign('pbReset','<a href="javascript:document.regform.reset()"><img '.createLDImgSrc($root_path,'reset.gif','0').' alt="'.$LDResetData.'" align="absmiddle"></a>');

$smarty->assign('sMainBlockIncludeFile','usuarios/registrar_usuario.tpl');

/**
* show Template
*/
$smarty->display('common/mainframe.tpl');
?>